package easy;

public class test2 {
    // https://leetcode.cn/problems/check-permutation-lcci/submissions/680690333/
    public boolean CheckPermutation(String s1, String s2) {
        if(s1.length()!=s2.length()) return false;
        int[] hash=new int[26];
        for(int i=0;i<s1.length();i++) {
            char ch=s1.charAt(i);
            hash[ch-97]++;
        }
        for(int i=0;i<s2.length();i++) {
            char ch=s2.charAt(i);
            if(hash[ch-97]==0) {
                return false;
            } else {
                hash[ch-97]--;
            }
        }
        for(int i=0;i<hash.length;i++) {
            if(hash[i]!=0) return false;
        }
        return true;
    }
}
